﻿using Abp.Web.Mvc.Controllers;
using Abp.WebApi.Controllers;
using System.Web.Mvc;

namespace RMM.Web.Controllers
{
    /// <summary>
    /// Derive all Controllers from this class.
    /// </summary>
    public abstract class RMMControllerBase : AbpController
    {
        public JsonResult Success(object obj)
        {
            return Json(new JsResult(obj));
        }

        public JsonResult Fail(string msg)
        {
            return Json(new JsResult(null, -1, msg));
        }

        public JsonResult AuthorizeFail()
        {
            return Json(new JsResult(null, -999, "登陆超时"), JsonRequestBehavior.AllowGet);
        }

        protected RMMControllerBase()
        {
            LocalizationSourceName = RMMConsts.LocalizationSourceName;
        }
    }


    public class JsResult
    {
        public JsResult(object obj, int code = -1, string msg = "")
        {
            code = this.code;
            msg = this.msg;
            obj = this.data;
        }

        public int code { get; set; }

        public string msg { get; set; }

        public object data { get; set; }
    }
}